package com.itheima.sh.homeWork04;

import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class StudentTest {
    public static void main(String[] args) {
        List<Student> stuList = new ArrayList<>();
        stuList.add(new Student("张三", "男", "20", "88"));
        stuList.add(new Student("李四", "女", "19", "99"));

        for (Student student : stuList) {
            try (FileWriter fw = new FileWriter("D:/ITheima/student.txt", true);) {

                fw.write(student.getName() + "," + student.getSex() + "," + student.getAge() + "," + student.getScore() + "\r\n");
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    }


}

